package main

import "fmt"

func duan01() {
	fmt.Println("我是断言")
}
func main() {
	//创建接口断言
	var a interface{}
	a = 100
	v, ok := a.(int)
	if ok {
		fmt.Println("是整形", v)

	} else {
		fmt.Println("不是整型数据")
	}
	var duand []interface{}
	duand = append(duand, 10, 20, "dd", duan01)
	fmt.Println("duand=", duand)
	//两种输出方式
	for _, v := range duand {
		if data, ok := v.(int); ok {
			fmt.Println("整型", data)
		} else if data, ok := v.(func()); ok {
			fmt.Println("函数", data)
			duan01()
		}

	}
	fmt.Println("_______________")
	//第二种方式
	for _, v01 := range duand {
		switch l := v01.(type) {
		case int:
			fmt.Println("整型", l)
		case string:
			fmt.Println("字符串", l)
		case func():
			fmt.Println("函数", l)
			l()

		}

	}
}
